{include file="public/header" /}

</head>
<body class="layui-anim" style="background: #fff;">
<div class="x-nav layui-row">
	<span class="layui-breadcrumb layui-col-md9 layui-col-sm9">
		<!-- <a href="javascript:;">首页</a> -->
		<!-- {if $_page_navi.0}<a href="javascript:;">{$_page_navi.0.NavName}</a>{/if} -->
		<!-- {if $_page_navi.1}{/if} -->
		<a><cite>{$_page_navi.1.title}</cite></a>
	</span>
	<!-- <a class="layui-btn layui-btn-small" style="float:right" href="javascript:location.replace(location.href);"
	   title="刷新"><i class="layui-icon">&#xe9aa;</i></a> -->
</div>
<div class="x-body">
	<blockquote class="layui-elem-quote layui-clear " style="">
		<!-- <span style="font-size: 16px;"><i class="layui-icon">&#xe653;</i>&nbsp;{$_page_navi.1.NavName}</span> -->
		<form class="layui-form layui-col-md8 x-so layui-form-pane x-right" style="margin: 0;text-align: right;">
			<input class="layui-input" placeholder="手机号/编号/用户名" name="keyword" value="{$Request.param.keyword}"/>
			<button class="layui-btn" lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
			<!-- {if $Request.param.keyword}
			<a href="{:url('User/recommend')}" class="layui-btn layui-bg-blue">撤销搜索</a>
			{/if} -->
		</form>
	</blockquote>
	{if $first}
	<div class="layui-tree layui-form layui-tree-line" lay-filter="LAY-tree-1">


		<div class="layui-tree-set layui-tree-spread layui-tree-setHide">
			<div class="layui-tree-entry opens" data-id="{$first.id}">
				<div class="layui-tree-main">
					<span class="layui-tree-iconClick layui-tree-icon">
						<i class="layui-icon layui-icon-addition"></i>
					</span>
					<span class="layui-tree-txt">{$first.title}</span>
				</div>
			</div>
			<div class="tp_{$first.id}">

			</div>
		</div>
	</div>
	{else}
	<h3 style="text-align: center">无数据</h3>
	{/if}
	<script id="template" type="text/html">
		{{# for(var i=0;i<d.length ;i++){ }}
		<div class="layui-tree-pack layui-tree-lineExtend layui-tree-showLine" style="display: block">
			<div class="layui-tree-set">
				<div class="layui-tree-entry opens" data-id="{{d[i].id}}" >
					<div class="layui-tree-main">
						<span class="layui-tree-iconClick layui-tree-icon">
							<i class="layui-icon layui-icon-addition"></i>
						</span>
						<span class="layui-tree-txt">{{d[i].title}}</span>
					</div>
				</div>
				<div class="tp_{{d[i].id}}">

				</div>
			</div>
		</div>
		{{# } }}
	</script>

</div>
</body>
<script>
	layui.use(['laytpl'], function () {

		var laytpl = layui.laytpl;

		$('.layui-tree').on('click', '.opens', function(){
			var obj = $(this);
			var id = obj.attr('data-id');
			var open = obj.find('i').hasClass('layui-icon-subtraction');
			if(open){
				$('.tp_'+id).html('');
				obj.find('i').removeClass('layui-icon-subtraction').addClass('layui-icon-addition');
				return false;
			}
			layer.load(2);
			$.ajax({
				type: 'GET',
				url: '{:url("recommend")}',
				data:{id:id},
				dataType: "json",
				success: function (data) {
					layer.closeAll()
					var tpl = document.getElementById('template').innerHTML;
					laytpl(tpl).render(data.result, function (html) {
						$('.tp_'+id).html(html);
					});
					obj.find('i').removeClass('layui-icon-addition').addClass('layui-icon-subtraction');
				}
			});
		})
	});
</script>
</html>